
/*********************************************************************************/
#delimit;
cd "C:\Users\ejm5\Dropbox\IDS_PAPI";
use "C:\Users\ejm5\Dropbox\GSO Enterprise Census (1)\20130623_PanelData\2005to2011_panel_1052013.dta", clear;

#delimit;
generate firm_trend=iddn2*firm_age;

#delimit;
set more off;

xtset iddn2 year;



/*Table 1*/
#delimit;
generate inflation= (nominalgdp_- GDP_constant)/ GDP_constant;

#delimit;
generate invest_constant=investment*(1/inflation);
generate revenue_constant=revenues*(1/inflation);
generate asset_constant=assets*(1/inflation);
generate profit_constant=profits*(1/inflation);

replace owner_sex=owner_sex-1;
replace owner_sex=1 if owner_sex==.5;

tabstat labour revenue_constant asset_constant invest_constant profit_constant fdi owner_sex owner_birthyear qualification  if labour<10, stat(mean) by(year);
tabstat labour revenue_constant asset_constant invest_constant profit_constant fdi owner_sex owner_birthyear qualification  if labour>=10 & labour<100, stat(mean) by(year);
tabstat labour revenue_constant asset_constant invest_constant profit_constant fdi owner_sex owner_birthyear qualification  if labour>=100, stat(mean) by(year);
tabstat labour revenue_constant asset_constant invest_constant profit_constant fdi owner_sex owner_birthyear qualification, stat(mean) by(year);

tab year if labour<10 & private==1|fdi==1;
tab year  if labour>=10 & labour<100 & private==1|fdi==1;
tab year  if labour>=100 & private==1|fdi==1;
tab year if private==1|fdi==1 ;

/*Table 2*/
#delimit;
xi: reg ln_investment l.t_unweighted   if private==1|fdi==1 , cluster(pci_id);
#delimit;
outreg2 using PCI, bdec(3) sdec(3) e(all) replace;

xi: areg ln_investment l.t_unweighted   if private==1|fdi==1, absorb(pci_id) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted i.year  if private==1|fdi==1, absorb(pci_id) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted i.year i.pci_id  if private==1|fdi==1, absorb(ISICv4) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: reg ln_investment l.t_unweighted i.pci_id*year   if private==1|fdi==1 , cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: reg ln_investment l.t_unweighted owner_sex qualifications owner_age fdi  i.pci_id*year l.roads l.ln_pop l.tel_cap if private==1|fdi==1 , cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted  if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted i.year   if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted if private==1|fdi==1 , absorb(firm_trend) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted i.year   l.roads  l.ln_pop l.tel_cap   if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);
 
xi: areg ln_investment l.t_unweighted i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.t_unweighted i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using PCI, bdec(3) sdec(3) e(all) excel;


/*Table Transparency*/
#delimit;
xi: reg ln_investment l.tsub3_trans   if private==1|fdi==1 , cluster(pci_id);
#delimit;
outreg2 using TRANS, bdec(3) sdec(3) e(all) replace;

xi: areg ln_investment l.tsub3_trans   if private==1|fdi==1, absorb(pci_id) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans i.year  if private==1|fdi==1, absorb(pci_id) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans i.year i.pci_id  if private==1|fdi==1, absorb(ISICv4) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: reg ln_investment l.tsub3_trans i.pci_id*year   if private==1|fdi==1 , cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: reg ln_investment l.tsub3_trans owner_sex qualifications owner_age fdi  i.pci_id*year l.roads l.ln_pop l.tel_cap if private==1|fdi==1 , cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans  if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans i.year   if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans if private==1|fdi==1 , absorb(firm_trend) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans i.year   l.roads  l.ln_pop l.tel_cap   if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);
 
xi: areg ln_investment l.tsub3_trans i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all);

xi: areg ln_investment l.tsub3_trans i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using TRANS, bdec(3) sdec(3) e(all) excel;


xi: areg ln_investment l.ln_investment l.tsub3_trans l.roads  l.ln_pop l.tel_cap  i.year  if private==1|fdi==1, absorb(iddn2) cluster(pci_id)
outreg2 using lag_dv, bdec(3) sdec(3) e(all) replace;
xi: areg ln_investment l.ln_investment l.t_unweighted l.roads  l.ln_pop l.tel_cap  i.year  if private==1|fdi==1, absorb(iddn2) cluster(pci_id)
outreg2 using lag_dv, bdec(3) sdec(3) e(all) excel;

/***********************************************************************************************/

/*Model 1 - No Controls*/
reg ln_investment unweighted, cluster(pci_id);
outreg2 using no_controls, bdec(3) sdec(3) e(all) replace;


#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: reg ln_investment l.`x'   if private==1|fdi==1 , cluster(pci_id);
outreg2 using no_controls, bdec(3) sdec(3) e(all); 
};

#delimit;
outreg2 using no_controls, bdec(3) sdec(3) e(all) excel;


/*Model 2 - No Controls*/
reg ln_investment unweighted, cluster(pci_id);
outreg2 using province_FE, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x'   if private==1|fdi==1, absorb(pci_id) cluster(pci_id);
outreg2 using province_FE, bdec(3) sdec(3) e(all); 
};

#delimit;
outreg2 using province_FE, bdec(3) sdec(3) e(all) excel;


/*Model 3 - No Controls*/
reg ln_investment unweighted, cluster(pci_id);
outreg2 using year_FE, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' i.year  if private==1|fdi==1, absorb(pci_id) cluster(pci_id);
outreg2 using year_FE, bdec(3) sdec(3) e(all); 
};

#delimit;
outreg2 using year_FE, bdec(3) sdec(3) e(all) excel;

/*Model 4 - Sector FE*/
reg ln_investment unweighted, cluster(pci_id);
outreg2 using sector_FE, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' i.year i.pci_id  if private==1|fdi==1, absorb(ISICv4) cluster(pci_id);
outreg2 using sector_FE, bdec(3) sdec(3) e(all); 
};

#delimit;
outreg2 using sector_FE, bdec(3) sdec(3) e(all) excel;



/*Model 7 - Firm FE*/
#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm_fe, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x'  if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using firm_fe, bdec(3) sdec(3) e(all); 
};

#delimit;
outreg2 using firm_fe, bdec(3) sdec(3) e(all) excel;

/*Model 7 - Firm, Year FE*/
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm-year_fe, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' i.year   if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using firm-year_fe, bdec(3) sdec(3) e(all); 
};




#delimit;
outreg2 using firm-year_fe, bdec(3) sdec(3) e(all) excel;



/***********************************************************************/
/*Model 8 Province Time Trend*/
#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using province_trend, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: reg ln_investment l.`x' i.pci_id*year   if private==1|fdi==1 , cluster(pci_id);
outreg2 using province_trend, bdec(3) sdec(3) e(all); 
};

outreg2 using province_trend, bdec(3) sdec(3) e(all) excel;



#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using province_trend_con, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: reg ln_investment l.`x' owner_sex qualifications owner_age fdi  i.pci_id*year l.roads l.ln_gdp l.ln_pop l.tel_cap if private==1|fdi==1 , cluster(pci_id);
outreg2 using province_trend_con, bdec(3) sdec(3) e(all); 
};

outreg2 using province_trend_con, bdec(3) sdec(3) e(all) excel;

/*Model 9 Time Trend*/
#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm_trend, bdec(3) sdec(3) e(all) replace;

#delimit;
generate firm_trend=iddn2*firm_age;


#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' if private==1|fdi==1 , absorb(firm_trend) cluster(pci_id);
outreg2 using firm_trend, bdec(3) sdec(3) e(all); 
};

outreg2 using firm_trend, bdec(3) sdec(3) e(all) excel;



#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm_trend_con, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x'  owner_sex qualifications owner_age fdi l.roads  l.ln_pop l.tel_cap if private==1|fdi==1 , absorb(firm_trend) cluster(pci_id);
outreg2 using firm_trend_con, bdec(3) sdec(3) e(all); 
};

outreg2 using firm_trend_con, bdec(3) sdec(3) e(all) excel;


/*Firm FE, Year FE, and Time Variant Controls*/


#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm_yfe_con, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap   if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using firm_yfe_con, bdec(3) sdec(3) e(all); 
};

outreg2 using firm_yfe_con, bdec(3) sdec(3) e(all) excel;


/*Model 10 Tobit*/
#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using tobit, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in t_unweighted tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: tobit ln_investment l.`x' owner_sex qualifications owner_age fdi  i.pci_id*year l.roads l.ln_gdp l.ln_pop l.tel_cap if private==1|fdi==1 , ll(0) cluster(pci_id);
outreg2 using tobit, bdec(3) sdec(3) e(all); 
};

outreg2 using tobit, bdec(3) sdec(3) e(all) excel;




/**************************FDI versus Private**************************************************/

#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm_firm_yfe_privfdi, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap   if private==1, absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_privfdi, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap   if fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_privfdi, bdec(3) sdec(3) e(all); 
};

outreg2 using firm_firm_yfe_privfdi, bdec(3) sdec(3) e(all) excel;




/**************************Size**************************************************/

#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm_firm_yfe_large, bdec(3) sdec(3) e(all) replace;


#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap   if large_firm==1, absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_large, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap   if large_firm==0, absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_large, bdec(3) sdec(3) e(all); 
};

outreg2 using firm_firm_yfe_large, bdec(3) sdec(3) e(all) excel;








#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using firm_firm_yfe_largefdi, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted{;
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_largefdi, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_largefdi, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_largefdi, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using firm_firm_yfe_largefdi, bdec(3) sdec(3) e(all); 
};
outreg2 using firm_firm_yfe_largefdi, bdec(3) sdec(3) e(all) excel;




/**********************************************************************************************************************************/
/*All Naive-Transparency*/
#delimit;
cd "C:\Users\ejm5\Dropbox\IDS_PAPI";



/*Trans Model 1*/
#delimit;
reg ln_investment l.tsub3_trans, cluster(pci_id);
outreg2 using transparency1, bdec(3) sdec(3) e(all) replace;


#delimit;
set more off;
foreach x in planning_avg legal_avg f2_new g94_new f7_new web_04 dim3_1_access dim3_2_equity dim3_3_predict dim3_4_open{;
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap   if private==1|fdi==1, absorb(iddn2) cluster(pci_id);
outreg2 using transparency1, bdec(3) sdec(3) e(all); 
};

outreg2 using transparency1, bdec(3) sdec(3) e(all) excel;


#delimit;
reg ln_investment unweighted, cluster(pci_id);
outreg2 using transparency3, bdec(3) sdec(3) e(all) replace;

#delimit;
set more off;
foreach x in planning legal f2_new g94_new f7_new web_04 dim3_1_access dim3_2_equity dim3_3_predict dim3_4_open{;
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using transparency3, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==0 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using transparency3, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==0 , absorb(iddn2) cluster(pci_id);
outreg2 using transparency3, bdec(3) sdec(3) e(all); 
xi: areg ln_investment l.`x' i.year   l.roads  l.ln_pop l.tel_cap  if large_firm==1 & fdi==1 , absorb(iddn2) cluster(pci_id);
outreg2 using transparency3, bdec(3) sdec(3) e(all); 
};
outreg2 using transparency3, bdec(3) sdec(3) e(all) excel;



/************************************************INTERACTIONS**************************************/




xi: areg ln_investment c.lag_trans3##c.lag_hhirev  fdi  l.roads  l.ln_pop l.tel_cap , absorb(firm_trend) robust cluster(pci_id)  
margins, dydx(lag_trans3) at(lag_hhirev=(0(.01).45)) vsquish post atmeans level(90)
marginsplot




xi: areg ln_investment c.fdi##c.lag_planning large_firm   l.roads  l.ln_pop l.tel_cap , absorb(year)  cluster(pci_id)
margins, dydx(lag_planning) at(fdi=(0(1)1)) vsquish post atmeans level(90)
marginsplot
graph save fdi_planning.gph, replace

xi: areg ln_investment c.fdi##c.lag_trans3 large_firm   l.roads  l.ln_pop l.tel_cap , absorb(year)  cluster(pci_id)
margins, dydx(lag_planning) at(fdi=(0(1)1)) vsquish post atmeans level(90)
marginsplot
graph save fdi_trans.gph, replace


xi: areg ln_investment fdi##large_firm##c.lag_planning large_firm   l.roads  l.ln_pop l.tel_cap , absorb(year)  cluster(pci_id)
margins, dydx(lag_planning) over(large_firm) at(fdi=(0(1)1)) vsquish post atmeans level(90)
marginsplot, xdimension(large_firm) bydimension(lag_planning) xlabel(, angle(45))



xi: areg ln_investment c.lag_trans3##i.fdi c.lag_trans3##i.large_firm  i.year, robust cluster(pci_id) absorb(iddn2) 
preserve
margins, dydx(fdi) at(lag_trans3=(1(1)10)) vsquish post atmeans level(90)
matrix at=e(at)
matrix at=at[1...,"lag_trans3"]
matrix list at
parmest, norestore level(90)
svmat at
twoway (line estimate at1)(line min90 at1)(line max90 at1), legend(off) yline(0) xtitle(Lagged Transaprency) ytitle(Marginal Effect of HHI on Transparency)





/*******************************************************************TRENDS*********************************************/
#delimit;
use "C:\Users\ejm5\Dropbox\IDS_PAPI\data\PCI_ts_provincelevel.dta", clear;
preserve;
collapse (median) tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted, by(year);
generate type=1;
save median_ts.dta, replace; 
restore;
preserve;
collapse (max) tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted, by(year);
generate type=2;
save max_ts.dta, replace; 
restore;
collapse (min) tsub1_entry tsub2_land tsub3_trans tsub4_time tsub5_informal tsub6_bias tsub7_proactivity tsub8_psd tsub9_labor tsub10_legal t_unweighted, by(year);
generate type=3;
save min_ts.dta, replace; 

#delimit;
append using median_ts.dta;
append using max_ts.dta;
drop if tsub1_entry==.;
xtset type year;



#delimit;
twoway (line tsub1_entry year if type==1, lcolor(navy) lwidth(thick)) (line tsub1_entry year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub1_entry year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Entry Costs", size(large));
graph save sub1.gph, replace;

#delimit;
twoway (line tsub2_land year if type==1, lcolor(navy) lwidth(thick)) (line tsub2_land year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub2_land year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Land Access", size(large));
graph save sub2.gph, replace;

#delimit;
twoway (line tsub3 year if type==1, lcolor(navy) lwidth(thick)) (line tsub3 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub3 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Transparency", size(large));
graph save sub3.gph, replace;

#delimit;
twoway (line tsub4 year if type==1, lcolor(navy) lwidth(thick)) (line tsub4 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub4 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Time Costs", size(large));
graph save sub4.gph, replace;

#delimit;
twoway (line tsub5 year if type==1, lcolor(navy) lwidth(thick)) (line tsub5 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub5 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Informal Charges", size(large));
graph save sub5.gph, replace;

#delimit;
twoway (line tsub6 year if type==1, lcolor(navy) lwidth(thick)) (line tsub6 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub6 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("SOE Bias", size(large));
graph save sub6.gph, replace;

#delimit;
twoway (line tsub7 year if type==1, lcolor(navy) lwidth(thick)) (line tsub7 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub7 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Proactivity", size(large));
graph save sub7.gph, replace;

#delimit;
twoway (line tsub8 year if type==1, lcolor(navy) lwidth(thick)) (line tsub8 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub8 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Biz Services", size(large));
graph save sub8.gph, replace;


#delimit;
twoway (line tsub9 year if type==1, lcolor(navy) lwidth(thick)) (line tsub9 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub9 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Labor", size(large));
graph save sub9.gph, replace;

#delimit;
twoway (line tsub10 year if type==1, lcolor(navy) lwidth(thick)) (line tsub10 year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line tsub10 year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(1(1)10, labsize(small)) ytitle("", size(medium)) legend(off)
title("Legal", size(large));
graph save sub10.gph, replace;


#delimit;
twoway (line t_unweighted year if type==1, lcolor(navy) lwidth(thick)) (line t_unweighted year if type==2, lcolor(navy) lwidth(medthick) lpattern(dash)) (line t_unweighted year if type==3, lcolor(navy) lwidth(medthick) lpattern(dash)), 
xlab(2006(1)2009, labsize(small)) xtitle("") ylab(30(5)70, labsize(small)) ytitle("Index Score", size(medium) margin(medsmall)) legend(rows(3) size(vsmall)  position(8) ring(0) label(1 Median Prov.) label(2 Max. Prov.) label(3 Min. Prov.))
title("Total PCI", size(medium)) fysize(100) fxsize(40);
graph save pci.gph, replace;


#delimit;
graph combine sub1.gph sub2.gph sub3.gph sub4.gph sub5.gph sub6.gph sub7.gph sub8.gph sub9.gph sub10.gph , xcommon rows(2);
graph save subindices.gph, replace;

#delimit;
graph combine pci.gph subindices.gph, cols(2);
graph save ts.gph, replace;




